package main

import "fmt"

// go语言的继承实际为组合，而非真正的继承
type DefaultPlayer struct {
	name string
}

func (d *DefaultPlayer) train() {
	fmt.Println("默认的训练")
}

func (d *DefaultPlayer) sign() {
	fmt.Println(d.name, "签到")
	d.train()
}

type FootballPlayer struct {
	DefaultPlayer
}

func (f *FootballPlayer) train() {
	fmt.Println("足球运动员的训练")
}

type Basketball struct {
	DefaultPlayer
}

func (f *Basketball) train() {
	fmt.Println("篮球运动员的训练")
}

type SwimmingPlayer struct {
	DefaultPlayer
}

func (f *SwimmingPlayer) train() {
	fmt.Println("游泳运动员的训练")
}

func main() {
	//defaultPlayer中没有指向FootballPlayer的对象，因此不能调用FootballPlayer的train方法
	//如果要在go中实现多态，就要考虑使用接口
	a := FootballPlayer{DefaultPlayer{"A"}}
	a.sign()

	b := Basketball{DefaultPlayer{"B"}}
	b.sign()

	s := SwimmingPlayer{DefaultPlayer{"C"}}
	s.sign()

	//A 签到
	//默认的训练
	//B 签到
	//默认的训练
	//C 签到
	//默认的训练
}
